package com.smalldoor.thread.demo03;

import java.text.SimpleDateFormat;
import java.util.Date;

//模拟时间
public class SleepThread02 {

    public static void main(String[] args) {
        while (true) {
            try {
                Thread.sleep(1000);
                System.out.println(new SimpleDateFormat("HH:mm:ss").format(new Date(System.currentTimeMillis())));
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }

    public static void tenDown() {
        int num = 10;
        while (true) {
            try {
                Thread.sleep(1000);
                System.out.println(num--);
                if (num <= 0 ){
                    break;
                }
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }

}
